package com.keyue.controller;


import com.keyue.common.annotation.AnonymousAccess;
import com.keyue.common.constant.ServerResult;
import com.keyue.domain.vo.admin.AdminJobQueryVO;
import com.keyue.domain.vo.admin.AdminJobVO;
import com.keyue.log.Log;
import com.keyue.service.admin.AdminJobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @date 2019-03-29
 */
@Api(tags = "系统：岗位管理")
@RestController
@RequestMapping("/keyue/admin/jobs")
public class JobController {

    @Resource
    private AdminJobService jobService;

    @Log("查询岗位")
    @ApiOperation("查询岗位")
    @PostMapping(value = "/list_by_page")
    @AnonymousAccess
    public ServerResult listByPage(@RequestBody @Validated AdminJobQueryVO queryVO) {
        return jobService.list(queryVO);
    }

    @Log("新增岗位")
    @ApiOperation("新增岗位")
    @PostMapping(value = "/add")
    @AnonymousAccess
    public ServerResult add(@RequestBody @Validated AdminJobVO jobVO) {
        return jobService.add(jobVO);
    }

    @Log("修改岗位")
    @ApiOperation("修改岗位")
    @PostMapping(value = "/edit")
    @AnonymousAccess
    public ServerResult edit(@RequestBody @Validated AdminJobVO jobVO) {
        return jobService.edit(jobVO);
    }

    @Log("删除岗位")
    @ApiOperation("删除岗位")
    @PostMapping(value = "/delete")
    @AnonymousAccess
    public ServerResult delete(@RequestBody @Validated AdminJobQueryVO queryVO) {
        return jobService.deleteById(queryVO);
    }
}